package download

import (
	"fmt"
	"io"
	"net/http"
	"novelDownlaod/config"
	"os"
)

func Download(url string) {
	res, err := http.Get(url)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(0)
	}
	defer res.Body.Close()
	//var p []byte
	//res.Body.Read(p)
	//fmt.Println(string(p))
	//
    file,err:=os.Create(config.BookName+".txt")
    n,err:=io.Copy(file,res.Body)
    fmt.Println(n)
	//if err != nil {
	//	fmt.Println(err)
	//	os.Exit(0)
	//}
	//file.Write(p)
}
